package com.usian.controller;

import com.usian.pojo.User;
import com.usian.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
@RefreshScope
public class UserController {

    @Autowired
    private UserService userService;

    @Value("${config.info}")
    private String configInfo;


    @RequestMapping("findById/{id}/{name}")
    public User findById(@PathVariable Integer id,@PathVariable String name){
        System.out.println(configInfo);
        System.out.println(name);
        return  userService.findById(id);
    }
    @GetMapping("findByIdd")
    public User findByIdd(@RequestParam  Integer id,String name){
        System.out.println(name);
        return userService.findById(id);
    }

    @PostMapping("findByUser")
    public User findByUser(@RequestBody  User user){
        System.out.println(user.toString());
        return userService.findById(user.getId());

    }

}
